java AndroidStudio:如何在片段中移动按钮
我如何在一个片段中移动Android Studio元素,比如按钮或文本视图?在一个活动中,我可以使用拖放按钮;下降,但这似乎不适用于碎片。 所以现在我的按钮在左拐角,但是我希望把它们放在中间。
<FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context="com.example.test.fragmenttest.BlankFragment">
<Button
安卓:id="@+id/button"
安卓:layout_width="150dp"
安卓:layout_height="wrap_content"
安卓:text="Button" />
</FrameLayout>
# 1 楼答案
如果您使用的是片段或活动,则没有区别,这都与您的布局类型有关。尝试使用ConstraintLayout而不是您的,或者在框架布局中设置
android:gravity="center"
或者: